package com.hudson.plugin.server.hibernateDB.internal.domain.entity;

import javax.persistence.*;

/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 5/29/11
 * Time: 12:24 PM
 * To change this template use File | Settings | File Templates.
 */
@Table(name = "promotion_builds", catalog = "reportdb")
@Entity
public class PromotionBuildsEntity {
    private int id;

    @Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    private String promotionNum;

    @Column(name = "promotion_num", nullable = true, insertable = true, updatable = true, length = 32, precision = 0)
    @Basic
    public String getPromotionNum() {
        return promotionNum;
    }

    public void setPromotionNum(String promotionNum) {
        this.promotionNum = promotionNum;
    }

    private String author;

    @Column(name = "author", nullable = true, insertable = true, updatable = true, length = 32, precision = 0)
    @Basic
    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    private String result;

    @Column(name = "result", nullable = true, insertable = true, updatable = true, length = 12, precision = 0)
    @Basic
    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    private int duration;

    @Column(name = "duration", nullable = true, insertable = true, updatable = true, length = 10, precision = 0)
    @Basic
    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    private String buildOn;

    @Column(name = "build_on", nullable = true, insertable = true, updatable = true, length = 256, precision = 0)
    @Basic
    public String getBuildOn() {
        return buildOn;
    }

    public void setBuildOn(String buildOn) {
        this.buildOn = buildOn;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        PromotionBuildsEntity that = (PromotionBuildsEntity) o;

        if (duration != that.duration) return false;
        if (id != that.id) return false;
        if (author != null ? !author.equals(that.author) : that.author != null) return false;
        if (buildOn != null ? !buildOn.equals(that.buildOn) : that.buildOn != null) return false;
        if (promotionNum != null ? !promotionNum.equals(that.promotionNum) : that.promotionNum != null) return false;
        if (result != null ? !result.equals(that.result) : that.result != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result1 = id;
        result1 = 31 * result1 + (promotionNum != null ? promotionNum.hashCode() : 0);
        result1 = 31 * result1 + (author != null ? author.hashCode() : 0);
        result1 = 31 * result1 + (result != null ? result.hashCode() : 0);
        result1 = 31 * result1 + duration;
        result1 = 31 * result1 + (buildOn != null ? buildOn.hashCode() : 0);
        return result1;
    }

    private PromotionsEntity promotionsByPromotionId;

    @ManyToOne
    public
    @JoinColumn(name = "promotion_id", referencedColumnName = "id")
    PromotionsEntity getPromotionsByPromotionId() {
        return promotionsByPromotionId;
    }

    public void setPromotionsByPromotionId(PromotionsEntity promotionsByPromotionId) {
        this.promotionsByPromotionId = promotionsByPromotionId;
    }
}
